﻿Public Class fListaFormasPago
    Private lFP As String
    Private lDias As Integer
    Public ReadOnly Property FP() As String
        Get
            Return lfp
        End Get
    End Property
    Public ReadOnly Property Dias() As Integer
        Get
            Return lDias
        End Get
    End Property

    
    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnBuscar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
        Try
            Dim daFP As New lbGlobalcom.dsCarteraTableAdapters.CAR_FORMASPAGOTableAdapter
            DsCartera.CAR_FORMASPAGO.Rows.Clear()
            daFP.FillByLikeFP(DsCartera.CAR_FORMASPAGO, "%" & Me.txtFP.Text & "%")
            CAR_FORMASPAGODataGridView.Focus()
        Catch ex As Exception
            lbGlobalcom.cError.SalvaError(ex, "Samuel")
            MessageBox.Show(ex.Message)
        End Try
    End Sub


    Private Sub CAR_FORMASPAGODataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles CAR_FORMASPAGODataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lFP = CAR_FORMASPAGODataGridView.Rows(e.RowIndex).Cells("IDFORMAPAGO").Value
            lDias = CAR_FORMASPAGODataGridView.Rows(e.RowIndex).Cells("NDIAS").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub AsignaFormaPago(ByVal Fila As Integer)
        If Fila >= 0 Then
            lFP = CAR_FORMASPAGODataGridView.Rows(Fila).Cells("IDFORMAPAGO").Value
            lDias = CAR_FORMASPAGODataGridView.Rows(Fila).Cells("NDIAS").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub CAR_FORMASPAGODataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CAR_FORMASPAGODataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaFormaPago(CAR_FORMASPAGODataGridView.CurrentRow.Index)
        End If
    End Sub
End Class